<template>
  <el-menu class="el-menu-demo" mode="horizontal" :ellipsis="false" :default-active="activeIndex"
    @select="handleSelect">
    <el-menu-item v-for="(item, index) in menuList" :index="item.path" :key="index">{{ item.meta.title }}</el-menu-item>
  </el-menu>
</template>

<script lang="ts" setup>
import { computed, ref, watch } from 'vue';
import { useRouter } from 'vue-router';
import { useAuthStore } from "@/stores/modules/auth";

const router = useRouter();
const activeIndex = ref('/title');

const authStore = useAuthStore();
const menuList = computed(() => authStore.showMenuListGet);

const emit = defineEmits<{
  (e: 'menu-select', path: string): void;
}>();
const handleSelect = (path: string) => {
  activeIndex.value = path;
  router.push(path);
  emit('menu-select', path);
};
</script>

<style scoped lang="scss">
.el-menu-item.is-active::before {
  background-color: transparent;
}

.el-menu--horizontal.el-menu {
  margin-bottom: 5px;
}
</style>
